package com.example;

import com.example.config.SocketServer;
import com.example.config.udpsocket.UDPSocketServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.EnableScheduling;
import java.io.IOException;

@SpringBootApplication
//@MapperScan("com.example.config.*")
@EnableScheduling
@EnableCaching
public class MaterialsApplication {

    public static void main(String[] args) throws IOException {
        ApplicationContext applicationContext = SpringApplication.run(MaterialsApplication.class, args);
        //在spring容器启动后，取到已经初始化的SocketServer，启动Socket服务
        //UDPSocket启动(注意：tcpsocket启动会阻塞线程，还未优化，启动顺序udpsocket优先)
        applicationContext.getBean(UDPSocketServer.class).start();
        //TCPSocket启动
        applicationContext.getBean(SocketServer.class).start();
    }

}
